/**
 * 
 */
package com.softa.common.sysconfig.exception;

import com.softa.common.constant.Constants;
import com.softa.common.sysconfig.support.HttpCode;
import org.springframework.ui.ModelMap;

/**
 * 
 * @author panda
 */
@SuppressWarnings("serial")
public abstract class BaseException extends RuntimeException {

	private Integer msgCode = null;

	public BaseException() {
	}

	public BaseException(Throwable ex) {
		super(ex);
	}

	public BaseException(String message) {
		super(message);
	}

	public BaseException(String message, Throwable ex) {
		super(message, ex);
	}

    public BaseException(Integer msgCode, String message) {
        super(message);
        this.msgCode = msgCode;
    }

	public BaseException(Integer msgCode, String message, Throwable ex) {
        super(message, ex);
        this.msgCode = msgCode;
	}

	public void handler(ModelMap modelMap) {
		modelMap.put(Constants.EXCEPTION_CODE, getCode().value());
		modelMap.put(Constants.EXCEPTION_MSG, getMessage());
		modelMap.put(Constants.EXCEPTION_TIME, System.currentTimeMillis());
		modelMap.put(Constants.EXCEPTION_MSGCODE, msgCode);
	}

	public abstract HttpCode getCode();
}
